package com.ruoyi.purchase.feign.fallback;


import com.ruoyi.base.domain.Goods;
import com.ruoyi.base.domain.Inventory;
import com.ruoyi.base.domain.SettlementAccount;
import com.ruoyi.purchase.feign.client.GoodsFeignClient;
import com.ruoyi.common.core.web.domain.AjaxResult;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

@Component
public class GoodsFallbackFactory implements FallbackFactory<GoodsFeignClient> {
    @Override
    public GoodsFeignClient create(Throwable cause) {
        return new GoodsFeignClient() {
            @Override
            public Goods getGoodsById(Long id) {
                return new Goods();
            }

            @Override
            public AjaxResult insert(Inventory inventory) {
                return new AjaxResult(9999,"服务调用失败！！！");
            }

            @Override
            public AjaxResult updateInventory(Inventory inventory) {
                return new AjaxResult(9999,"服务调用失败！！！");
            }

            @Override
            public AjaxResult getInfo(Long id) {
                return new AjaxResult(9999,"服务调用失败！！！");
            }

            @Override
            public AjaxResult edit(SettlementAccount settlementAccount) {
                return new AjaxResult(9999,"服务调用失败！！！");
            }

            @Override
            public Inventory getByBarCode(String code) {
                return new Inventory();
            }
        };
    }
}
